<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>教学工作量统计系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/Public/layui/css/layui.css"  media="all">
  <!-- <link href="/Public/Home/styles/mypage.css" rel="stylesheet" type="text/css"/> -->
  <!-- <link rel="stylesheet" href="/Public/Home/styles/course.css"> -->
  <script src="/Public/layui/layui.js" charset="utf-8"></script>
  <script src="/Public/js/jquery-1.11.3.js" charset="utf-8"></script>
</head>
<body class="layui-layout-body">
  <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
      <div class="layui-logo" style="font-weight: bold;"><a style="color: #777;" href="http://www.sinon.com/index.php/Admin/index/index">WORKLOAD</a></div>
      <!-- 头部区域（可配合layui已有的水平导航） -->
     <!--  <ul class="layui-nav layui-layout-left">
        <li class="layui-nav-item"><a href="">控制台</a></li>
        <li class="layui-nav-item"><a href="">商品管理</a></li>
        <li class="layui-nav-item"><a href="">用户</a></li>
        <li class="layui-nav-item">
          <a href="javascript:;">其它系统</a>
          <dl class="layui-nav-child">
            <dd><a href="">邮件管理</a></dd>
            <dd><a href="">消息管理</a></dd>
            <dd><a href="">授权管理</a></dd>
          </dl>
        </li>
      </ul> -->
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item">
          <a href="javascript:;">
            <!-- <img src="http://t.cn/RCzsdCq" class="layui-nav-img"> -->
            cwy123
          </a>
          <dl class="layui-nav-child">
            <dd><a href="">基本资料</a></dd>
            <dd><a href="">安全设置</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="">注销</a></li>
      </ul>
    </div>

    <div class="layui-side layui-bg-black">
      <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree"  lay-filter="test">
          <li class="layui-nav-item layui-nav-itemed">
            <a class="" href="javascript:;">基础数据管理</a>
            <dl class="layui-nav-child">
              <dd><a href="http://www.sinon.com/index.php/Admin/Course/index">课程信息管理</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/Practice/index">课程设计信息管理</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/class/index">班级信息管理</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/major/index">专业信息管理</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/teacher/index">教师信息管理</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item layui-nav-itemed">
            <a href="javascript:;">教学任务管理</a>
            <dl class="layui-nav-child">
              <dd><a href="http://www.sinon.com/index.php/Admin/CourseTask/index">课程教学任务管理</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/DesignTask/index">课程设计任务管理</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/ProjectTask/index">毕业设计任务管理</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item layui-nav-itemed">
            <a href="javascript:;">工作量统计</a>
            <dl class="layui-nav-child">
              <dd><a href="http://www.sinon.com/index.php/Admin/ProjectWorkload/index">毕业设计工作量统计</a></dd>
              <dd><a href="http://www.sinon.com/index.php/Admin/Workload/index">教学总工作量统计</a></dd>
            </dl>
          </li>
        </ul>
      </div>
    </div>

    <div class="layui-body">
      <!-- 内容主体区域 -->
      <div class="topic">用户管理</div>
      <div style="height: 10px;"></div>
      <div><a href="http://www.sinon.com/index.php/Admin/User/add" class="layui-btn xinzeng" >添加用户</a></div>
      
      <table id="user_demo" lay-filter="test"></table>
      <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
      </script>
    </div>

<div class="layui-footer">
      <!-- 底部固定区域 -->
      © Design by tarkasi 2018
    </div>
  </div>
</body>
</html>



<script>
  layui.use('table', function(){
    var table = layui.table;

    //表格实例
    table.render({
      elem: '#user_demo',
      url: '<?php echo U("index");?>',
      method: 'post',
      cols: [[ //标题栏
          // {checkbox: true, fixed: true, width:"5%"},
          {field: 'username', title: '用户登录名', width: "20%"},
          {field: 'password', title: '用户密码', width: "20%"},
          {field: 'note', title: '备注', width: "20%"},
          {field: 'right', title: '操作', align:'center', toolbar: '#barDemo', width:"20%"},
      ]],
      skin: 'row', //表格风格
      even: true,
      cellmore:true,
      id: 'testReload',
      page: true, //是否显示分页
      limits: [5, 10, 20],
      limit: 10 //每页默认显示的数量
  });

    //监听工具条
    table.on('tool(test)', function(obj){
      var data = obj.data; //获得当前行数据
      var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
      var tr = obj.tr; //获得当前行 tr 的DOM对象
      if(obj.event === 'detail'){ //查看操作
        //do somehing
      } else if(obj.event === 'del'){
        layer.confirm('确定要删除吗', function(index){
          
          console.log(data);
          $.ajax({
            url: '<?php echo U("User/del");?>',
            type: "POST",
            data:data,
            dataType: "json",
            success: function(data){
              if (data == 1){
              //删除这行数据
              obj.del();
              //关闭弹框
              layer.close(index);
              layer.msg("删除成功", {icon: 6});
              window.location.reload(); //刷新当前页面
              }else{
                layer.msg("删除失败", {icon: 5});
              }
            }
          });
        });
      } 
    });
  });
</script>

<style>
  .xinzeng{
    margin: 0 10px;
  }
  .topic{
    width: 100%;
    height: 40px;
    line-height: 40px;
    font-size: 20px;
    font-family: Arial;
    text-align: center;
    background: #e6e6e6;
    color: #666;
  }
</style>